package _Trash;

import java.io.IOException;
import java.util.ArrayList;

import org.apache.lucene.analysis.standard.StandardAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.index.CorruptIndexException;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.store.LockObtainFailedException;

public class Indexer {

	/**
	 * @param args
	 */
	public static void main(String[] args) {


		MyParser parser = new MyParser();
		
		String[] files = {"nt", "ot", "bom", "quran"};

		try {
			IndexWriter indexer = new IndexWriter("index", new StandardAnalyzer(),true);
			for(String coll : files) {
				String collection = "rel200/"+coll+"/"+coll+".xml";
				System.out.println("Indexing: "+collection);

				ArrayList<Document> docs = parser.parse(collection);

				for(Document d : docs) {
					indexer.addDocument(d);				//just index docs1 for now
				}
			}
			System.out.println("Optimizing...");
			indexer.optimize();
			indexer.close();
		} catch (CorruptIndexException e) {
			e.printStackTrace();
		} catch (LockObtainFailedException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}

		System.out.println("---END---");



	}

}
